package
{
	import flash.display.DisplayObject;
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;

	public class TextButton extends SimpleButton
	{
		private var _text:String;
		private var _width:uint;
		private var _height:uint;
		
		public function TextButton(text:String, width:uint, height:uint) {
			_text = text;
			_width = width;
			_height = height;
			
			upState = makeState(false);
			overState = makeState(true);
			downState = makeState(true);
			hitTestState = makeState(false);
		}
		
		private function makeState(downState:Boolean):Sprite {
			var sprite:Sprite = new Sprite();
			var textField:TextField = new TextField();
			textField.height = _height;
			textField.background = true;
			textField.border = true;
			textField.backgroundColor = 0xFFFFFF;
			textField.text = _text;
			textField.width = _width;
			var format:TextFormat = new TextFormat();
			format.align = TextFormatAlign.CENTER;
			textField.setTextFormat(format);
			//textField.y = (_height - textField.textHeight)/2;
			//textField.y = 15;
			//textField.y -= 2;
			
			
			if (downState) {
				textField.backgroundColor = 0x000000;
				textField.textColor = 0xFFFFFF;
				//textField.x += 1;
				//textField.y += 1;
			}
			
			sprite.addChild(textField);
			return sprite;
		}
	}
}